home *** CD-ROM | disk | FTP | other *** search
/ IRIX 6.5 Applications 2002 November / SGI IRIX 6.5 Applications 2002 November.iso / dist / gateway.idb / usr / WebFace / Source / 20-NetworkServices / nsd / adv-config.frm.z / adv-config.frm
Encoding:
Text File  |  2002-06-12  |  4.0 KB  |  135 lines

  1. #!/usr/bin/perl5
  2. #
  3. # adv-config.frm
  4. #
  5. # Copyright 1988-1996 Silicon Graphics, Inc.
  6. # All rights reserved.
  7. #
  8. # This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
  9. # the contents of this file may not be disclosed to third parties, copied or
  10. # duplicated in any form, in whole or in part, without the prior written
  11. # permission of Silicon Graphics, Inc.
  12. #
  13. # RESTRICTED RIGHTS LEGEND:
  14. # Use, duplication or disclosure by the Government is subject to restrictions
  15. # as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
  16. # and Computer Software clause at DFARS 252.227-7013, and/or in similar or
  17. # successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
  18. # rights reserved under the Copyright Laws of the United States.
  19. #
  20.  
  21. BEGIN { require "/usr/WebFace/lib/CGI.pm"; import CGI; }
  22. require "/usr/OnRamp/lib/OnRamp.pm";
  23. require "/usr/OnRamp/lib/java.pm";
  24.  
  25. $query = new CGI;
  26.  
  27. $nsswitch_cf  = "/etc/nsswitch.conf";
  28. $dummy        = "/etc/nsswitch.conf.tmp";
  29. $title        = "Unified Name Service";
  30. $help_page    = "adv-config-help.html";
  31.  
  32. if (! -e "/usr/etc/nsd")
  33. {
  34.     print "Content-type: text/html\n\n"
  35.         . "<html><head><title>$title</title>\n"
  36.         . "<body><center><h1>$title</h1></center>\n"
  37.         . "<i>The Unified Name Service (UNS) is available on "
  38.         . "IRIX versions 6.5 and higher.  For information "
  39.         . "about upgrading to IRIX 6.5, please contact your "
  40.         . "local Silicon Graphics sales representative.</i>\n"
  41.         . "</body></html>\n";
  42.     exit 0;
  43. }
  44.  
  45. $done = $ARGV[0];
  46. $instructions = "<blockquote>
  47.     Click on any of the following configuration buttons to modify 
  48.     the configuration for that map. When you are done configuring 
  49.     maps, use the \"Ok\" button to view your changes.
  50.     </blockquote><p>\n";
  51.  
  52.  
  53. $continue = "return (true)";
  54. $input = $dummy; 
  55. if ($done eq 'done') {
  56.     $message = "Your changes have been made.";
  57.     rename($dummy, $nsswitch_cf);
  58.     system("/sbin/chkconfig", "yp", "on") 
  59.         if ($query->param('chkconfig') == 1);
  60.     system("/etc/killall", "-HUP", "nsd");
  61.     $continue = "return (false)";
  62.     $input = $nsswitch_cf; 
  63. if (! $done || $done eq 'done') {
  64.     # Set up temporary file
  65.     open(NSSWITCH, $nsswitch_cf);
  66.     open(TEMP, ">$dummy");
  67.     while ($line = <NSSWITCH>) {
  68.         print TEMP $line;
  69.     }
  70.     close(TEMP);
  71.     close(NSSWITCH);
  72.     $continue = "return (false)";
  73. }
  74.  
  75. print $query->header;
  76. &generic;
  77.  
  78. sub generic {
  79.     local ($num_maps) = 0;
  80.     local ($count)    = &count_maps($input);
  81.  
  82.     &title_block($title);
  83.     &header_block($title);
  84.  
  85.     print $query->startform("POST", "adv-parse.cgi?do_summary", "", 
  86.         "NAME=StandardForm");
  87.  
  88.     print "<i>$message</i><p>\n";
  89.     print $instructions;
  90.  
  91.     print qq|<font size="+1"><center><table border=1>\n|;
  92.  
  93.     print "<tr valign=top><td><table>";
  94.     open(NSSWITCH, $input);
  95.     while ($line = <NSSWITCH>) {
  96.         if ($line =~ /^\s*[#\n\(]/) {
  97.             print TEMP "$line";
  98.             next;
  99.         }
  100.         @entlist = split(/\s+/, $line);
  101.         chop ($entlist[0]);
  102.         $entlist[0] =~ s/(\S+)\s*(\(\S+\)*)$/\1/g;
  103.         $map = $entlist[0];
  104.         $cur_maps++;
  105.         $rem = ($count % 2) + 1;
  106.         print "</table></td><td><table>\n" 
  107.             if ($cur_maps == (int($count/2) + $rem));
  108.         print qq|<tr><td>$map </td><td><input type=button value="Configure" 
  109.                  onClick='location="adv-parse.cgi?$map"'>\n|;
  110.     }
  111.     close(NSSWITCH);
  112.     print "</table>\n<tr><td colspan=2 align=center><br>\n";
  113.     print qq|<input type=button value="     Add New Maps     " 
  114.              onClick='location="adv-parse.cgi"'>|;
  115.     print "<br><br></td></tr>\n</tr></table><p>\n";
  116.  
  117.     print qq|<input type="submit" name="doit" value="     Ok     " 
  118.     onClick="$continue"></center></font>|;
  119.  
  120.     print $query->endform;
  121. }
  122.  
  123. sub count_maps {
  124.     local ($num_maps) = 0;
  125.  
  126.     open(NSSWITCH, $_[0]);
  127.     while ($line = <NSSWITCH>) {
  128.         next if ($line =~ /^\s*[#\n\(]/);
  129.         $num_maps++;
  130.     }
  131.     close(NSSWITCH);
  132.     $num_maps;
  133. }
  134.